<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class SystemMenu extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    public $searchable = [
        'menu_name',
        'module',
        'controller',
        'action',
        'methods',
        'menu_path',
        'header',
        'unique_auth',
    ];

    public $fillable = [
        'icon',
        'menu_name',
        'module',
        'controller',
        'api_url',
        'action',
        'methods',
        'params',
        'menu_path',
        'header',
        'unique_auth',
        'path',
    ];

    protected $defaultSortCriteria = ['sort,desc'];

    /**
     * 菜单的子类
     */
    public function children()
    {
        return $this->hasMany(SystemMenu::class,'pid','id');
    }
}
